package com.jiangjiang.eshop.commodity.operation;

import com.jiangjiang.eshop.commodity.service.CategoryService;
import com.jiangjiang.eshop.commodity.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * @ClassName RelatedCheckCategoryOperation
 * @Description TODO
 * @Author jhw
 * @Date 2021/7/9 15:34
 * @Version 1.0
 **/
@Component
@Scope("prototype")
public class RelatedCheckCategoryOperation extends AbstractCategoryOperation<Boolean> {

    /**
     * 商品管理DAO组件
     */
    private GoodsService goodsService;

    @Autowired
    public RelatedCheckCategoryOperation(CategoryService categoryService, GoodsService goodsService) {
        super(categoryService);
        this.goodsService = goodsService;
    }

    @Override
    protected Boolean doRealExecute(Category category) throws Exception {
        return goodsService.countByCategoryId(category.getCategoryId()) > 0;
    }
}
